<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateChatGroupDataStatic extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('chat_group_data_statistics', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('groupId')->default(0)->comment('群聊id');
            $table->unsignedInteger('shopId')->default(0)->comment('门店id');
            $table->unsignedInteger('sessionId')->default(0)->comment('会话id');
            $table->unsignedInteger('statisticData')->default(1)->comment('统计数值 默认为1');
            $table->unsignedInteger('type')->default(1)
                  ->comment('统计类型 1发起呼叫 2响应时长 3 客服介入 4问题答案有用 5问题答案无用');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');

            $table->index("groupId");
            $table->index("shopId");
            $table->index("sessionId");
            $table->index("type");

            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '群聊 - 客服数据表统计';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('chat_group_data_statistics');
    }
}
